<?php
namespace app\admin\controller;

class config extends Base
{
	public $name='config';
    public function index()
    {
		if ($this->request->isAjax()) {
			foreach(input('post.') as $key=>$val){
				db($this->name)->where('name',$key)->update(['value'=>$val]);
			}
			if(input('site_css')){
				\create_theme();
			}
			 
			$this->success("添加成功",url('index?pid='.input('pid')));
		}
        $map=[];
		$map['pid']=input('pid',1);
        $list = db($this->name)->where($map)->order("sort,id")->select();
		$this->assign('list', $list);
		$tab_list=db($this->name)->where('pid',0)->order("sort,id")->select();
		$this->assign('tab_list',$tab_list);
		
		\cookie('url',\request()->url());
        return $this->fetch();
    }
	

}
